package com.edu.exam.enums.examination;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 答题类型枚举
 *
 * <p>定义考试系统中学生答题的类型，包括单选题、多选题、填空题等题型。</p>
 *
 * @author System
 * @version 1.0.0
 * @since 2025-11-14
 */
public enum AnswerType implements BaseEnum {

    /** 单选题 */
    SINGLE_CHOICE("SINGLE_CHOICE", "单选题", "只有一个正确答案的选择题"),

    /** 多选题 */
    MULTIPLE_CHOICE("MULTIPLE_CHOICE", "多选题", "有多个正确答案的选择题"),

    /** 判断题 */
    TRUE_FALSE("TRUE_FALSE", "判断题", "判断对错的题目"),

    /** 填空题 */
    FILL_BLANK("FILL_BLANK", "填空题", "需要填写答案的题目"),

    /** 论述题 */
    ESSAY("ESSAY", "论述题", "需要详细论述的主观题"),

    /** 编程题 */
    PROGRAMMING("PROGRAMMING", "编程题", "需要编写代码的题目"),

    /** 文件上传 */
    FILE_UPLOAD("FILE_UPLOAD", "文件上传", "需要上传文件的题目"),

    /** 拖拽题 */
    DRAG_DROP("DRAG_DROP", "拖拽题", "需要拖拽操作的题目"),

    /** 排序题 */
    SORTING("SORTING", "排序题", "需要排序的题目"),

    /** 匹配题 */
    MATCHING("MATCHING", "匹配题", "需要匹配对应的题目"),

    /** 计算题 */
    CALCULATION("CALCULATION", "计算题", "需要计算结果的题目"),

    /** 绘图题 */
    DRAWING("DRAWING", "绘图题", "需要绘图的题目"),

    /** 录音题 */
    RECORDING("RECORDING", "录音题", "需要录音的题目"),

    /** 视频题 */
    VIDEO("VIDEO", "视频题", "需要录制视频的题目"),

    /** 实操题 */
    PRACTICAL("PRACTICAL", "实操题", "需要实际操作的题目");

    private final String code;
    private final String description;
    private final String detail;

    AnswerType(String code, String description, String detail) {
        this.code = code;
        this.description = description;
        this.detail = detail;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public String getDetail() {
        return detail;
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }

    public static AnswerType fromCode(String code) {
        for (AnswerType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown answer type code: " + code);
    }
}